package com.suxin.qrcode;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.common.BitMatrix;

import java.io.File;
import java.util.Hashtable;

/**
 * @author Tang
 * @classname MainTest
 * @description [  ]
 * @date 2022/8/8 16:57
 */
public class MainTest {

    public static void main(String[] args) throws Exception{
        String text = "你好";
        int width = 100;
        int height = 100;
        String format = "png";
        Hashtable hints= new Hashtable();
        hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
        BitMatrix bitMatrix = new MultiFormatWriter().encode(text, BarcodeFormat.QR_CODE, width, height,hints);
        File outputFile = new File("/Users/tanglonglong/Desktop/new.png");
        MatrixToImageWriter.writeToFile(bitMatrix, format, outputFile);
    }

}
